<?php

declare(strict_types=1);

namespace App\Mall\Model;

use Hyperf\Database\Model\Relations\HasMany;
use Hyperf\Database\Model\SoftDeletes;
use Mine\MineModel;

/**
 * @property int $id 主键
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 * @property string $deleted_at 
 * @property int $user_id 用户id
 * @property string $no 订单编号
 * @property string $source 来源game,mall
 * @property string $total_amount 总金额
 * @property string $pay_amount 支付金额
 * @property int $is_pay 支付0否1是2退款
 * @property string $pay_at 
 * @property int $status 1正常2取消3超时
 * @property string $ship_name 收货人
 * @property string $ship_phone 收货电话
 * @property string $ship_address 收货地址
 * @property int $shop_id 
 * @property string $symbol 
 * @property-read null|\Hyperf\Database\Model\Collection|MallOrderItem[] $item 
 */
class MallOrder extends MineModel
{
    use SoftDeletes;

    /**
     * The table associated with the model.
     */
    protected ?string $table = 'mall_order';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'created_at', 'updated_at', 'deleted_at', 'user_id', 'no', 'source', 'total_amount', 'pay_amount', 'is_pay', 'pay_at', 'status', 'ship_name', 'ship_phone', 'ship_address', 'shop_id', 'symbol'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'user_id' => 'integer', 'total_amount' => 'decimal:2', 'pay_amount' => 'decimal:2', 'is_pay' => 'integer', 'status' => 'integer', 'shop_id' => 'integer'];

    public function item(): HasMany
    {
        return $this->hasMany(MallOrderItem::class, 'order_id', 'id');
    }
}
